"use strict";
// 泛型 声明调用时才知道的类型
// 泛型的语法
function fn(msg) {
    return msg;
}
console.log(fn('hello'));
console.log(fn(100));
// 函数泛型
function getMax(arr) {
    return Math.max(...arr);
}
// var arr: number[]=[1,9,7,8,5,3]
console.log(getMax([1, 5, 6, 2, 9, 7]));
// 类泛型（创建一个能获取指令键值对的对象
class Cls1 {
    constructor(key, value) {
        this.key = key;
        this.value = value;
    }
    getKey() {
        return this.key;
    }
    getValur() {
        return this.value;
    }
}
var c1 = new Cls1('name', 15);
// 案例：使用class封装一个深拷贝的class
class CloneDeep {
    constructor(newValue) {
        this.value = JSON.parse(JSON.stringify(newValue));
    }
    getValur() {
        return this.value;
    }
}
var user = {
    name: 'zs',
    age: 11
};
console.log(new CloneDeep(user).getValur());
function getProperty(obj, key) {
    return obj[key];
}
var person = { name1: 'Alice', age: 30, email: 'alice@aa.com' };
var name1 = getProperty(person, 'name1');
var email = getProperty(person, 'email');
console.log(name1, email);
